const express = require("express");
const upload = require("../public/javascripts/upload");
var router = express.Router();

//用户头像
router.post("/usersAva", upload.multerUser().single("avatar"), (req, res) => {
    //获取表单传过来的数据  
    //console.log(req.file);
    res.send({
        status:200,
        file: req.file
    });
})
//作者头像
router.post("/writersAva", upload.multerWriter().single("avatar"), (req, res) => {
    //获取表单传过来的数据    
    res.send({
        body: req.body,
        file: req.file
    });
})
//推荐图片
router.post("/homeAva", upload.multerHome().single("pic"), (req, res) => {
    res.send({
        body: req.body,
        file: req.file
    })
})
//书籍封面
router.post("/bookAva", upload.multerBook().single("pic"), (req, res) => {
    res.send({
        body: req.body,
        file: req.file
    })
})
module.exports = router